package com.atguigu.gulimall.product.feign;

import com.atguigu.common.to.SkuReductionTo;
import com.atguigu.common.to.SpuBrandTo;
import com.atguigu.common.utils.R;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Yanglinfengkk
 * @FeignClient("gulimall-coupon")  服务名(远程调用)
 */
@FeignClient("gulimall-coupon")
public interface CouponFeignService {

    /**
     * 1.CouponFeignService.saveSpuBounds(对象);
     *      1).@RequestBody将这个对象转为Json
     *      2).SpringCloud给远程服务发送请求,找到gulimall-coupon(注册中心),
     *          给服务的/coupon/spubounds/save发送请求,将上一步转的Json放在请求体位置发送请求
     *      3).对方服务收到请求,请求体里有Json数据
     *          (@RequestBody SpuBrandTo spuBrandTo):将请求体的Json转为SpuBrandTo(要求字段属性名一一对应)
     *  总结: 只要Json数据模型是兼容的,双方服务无需使用同一个To
     * @param spuBrandTo
     * @return
     */
    @PostMapping("/coupon/spubounds/save")
    R saveSpuBounds(@RequestBody SpuBrandTo spuBrandTo);

    @PostMapping("/coupon/skufullreduction/saveInfo")
    R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
